]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
layout: Move keyboard slide animation to keyboard
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 11 Feb 2021 12:08:47 +0000 (13:08 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 17 Feb 2021 15:45:01 +0000 (15:45 +0000)
The animation handling is kinda split between layout (for the
keyboard slide), and keyboard (for the focus window slide). It
would be nice to have more fine grained control on those, so
move the animation handling altogether to keyboard.js as a start.

This is roughly similar, except that transformations apply to
the Keyboard actor, instead of the keyboardBox (its parent). We
now queue a relayout after the animation in order to update the
chrome tracking.

The only layering break now is that we emit
layoutManager::keyboard-visible-changed in keyboard.js, its
purpose will be dropped in future commits, so leave it there for
now.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1668>

js/ui/keyboard.js
js/ui/layout.js

index a579495ad66f61cd1006d1305eccf1565edc53e8..ef655e3e0e72ab0ddde4aff42dc34f035c489fd0 100644 (file)
@@ -8,12 +8,12 @@ const Signals = imports.signals;
 const InputSourceManager = imports.ui.status.keyboard;
 const IBusManager = imports.misc.ibusManager;
 const BoxPointer = imports.ui.boxpointer;
-const Layout = imports.ui.layout;
 const Main = imports.ui.main;
 const PageIndicators = imports.ui.pageIndicators;
 const PopupMenu = imports.ui.popupMenu;
 
-var KEYBOARD_REST_TIME = Layout.KEYBOARD_ANIMATION_TIME * 2;
+var KEYBOARD_ANIMATION_TIME = 150;
+var KEYBOARD_REST_TIME = KEYBOARD_ANIMATION_TIME * 2;
 var KEY_LONG_PRESS_TIME = 250;
 var PANEL_SWITCH_ANIMATION_TIME = 500;
 var PANEL_SWITCH_RELATIVE_DISTANCE = 1 / 3; /* A third of the actor width */
@@ -1168,7 +1168,6 @@ var KeyboardManager = class KeyBoardManager {
             this._keyboard.setCursorLocation(null);
             this._keyboard.destroy();
             this._keyboard = null;
-            Main.layoutManager.hideKeyboard(true);
         }
     }
 
@@ -1213,7 +1212,7 @@ var KeyboardManager = class KeyBoardManager {
 var Keyboard = GObject.registerClass(
 class Keyboard extends St.BoxLayout {
     _init() {
-        super._init({ name: 'keyboard', vertical: true });
+        super._init({ name: 'keyboard', reactive: true, vertical: true });
         this._focusInExtendedKeys = false;
         this._emojiActive = false;
 
@@ -1294,6 +1293,7 @@ class Keyboard extends St.BoxLayout {
 
         Main.layoutManager.untrackChrome(this);
         Main.layoutManager.keyboardBox.remove_actor(this);
+        Main.layoutManager.keyboardBox.hide();
 
         if (this._languagePopup) {
             this._languagePopup.destroy();
@@ -1742,7 +1742,7 @@ class Keyboard extends St.BoxLayout {
 
         Main.layoutManager.keyboardIndex = monitor;
         this._relayout();
-        Main.layoutManager.showKeyboard();
+        this.animateShow();
 
         this._setEmojiActive(false);
 
@@ -1774,10 +1774,56 @@ class Keyboard extends St.BoxLayout {
         if (this._keyboardRequested)
             return;
 
-        Main.layoutManager.hideKeyboard();
+        this.animateHide();
         this.setCursorLocation(null);
     }
 
+    animateShow() {
+        Main.layoutManager.keyboardBox.show();
+        this.ease({
+            translation_y: -this.height,
+            opacity: 255,
+            duration: KEYBOARD_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => {
+                this._animateShowComplete();
+            },
+        });
+        Main.layoutManager.emit('keyboard-visible-changed', true);
+    }
+
+    _animateShowComplete() {
+        let keyboardBox = Main.layoutManager.keyboardBox;
+        this._keyboardHeightNotifyId = keyboardBox.connect('notify::height', () => {
+            this.translation_y = -this.height;
+        });
+
+        // Queue a relayout so the keyboardBox can update its chrome region.
+        keyboardBox.queue_relayout();
+    }
+
+    animateHide(immediate) {
+        if (this._keyboardHeightNotifyId) {
+            Main.layoutManager.keyboardBox.disconnect(this._keyboardHeightNotifyId);
+            this._keyboardHeightNotifyId = 0;
+        }
+        this.ease({
+            translation_y: 0,
+            opacity: 0,
+            duration: immediate ? 0 : KEYBOARD_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_IN_QUAD,
+            onComplete: () => {
+                this._animateHideComplete();
+            },
+        });
+
+        Main.layoutManager.emit('keyboard-visible-changed', false);
+    }
+
+    _animateHideComplete() {
+        Main.layoutManager.keyboardBox.hide();
+    }
+
     resetSuggestions() {
         if (this._suggestions)
             this._suggestions.clear();
@@ -1813,7 +1859,7 @@ class Keyboard extends St.BoxLayout {
         if (show) {
             windowActor.ease({
                 y: windowActor.y - deltaY,
-                duration: Layout.KEYBOARD_ANIMATION_TIME,
+                duration: KEYBOARD_ANIMATION_TIME,
                 mode: Clutter.AnimationMode.EASE_OUT_QUAD,
                 onComplete: () => {
                     this._windowSlideAnimationComplete(window, -deltaY);
@@ -1822,7 +1868,7 @@ class Keyboard extends St.BoxLayout {
         } else {
             windowActor.ease({
                 y: windowActor.y + deltaY,
-                duration: Layout.KEYBOARD_ANIMATION_TIME,
+                duration: KEYBOARD_ANIMATION_TIME,
                 mode: Clutter.AnimationMode.EASE_IN_QUAD,
                 onComplete: () => {
                     this._windowSlideAnimationComplete(window, deltaY);
index 1a41a34beb88db6f04ee45225e0f3a9c0217dbbc..0c844bc49a494f6ce991d0514472ac8e704ed9ae 100644 (file)
@@ -13,7 +13,6 @@ const Params = imports.misc.params;
 const Ripples = imports.ui.ripples;
 
 var STARTUP_ANIMATION_TIME = 500;
-var KEYBOARD_ANIMATION_TIME = 150;
 var BACKGROUND_FADE_ANIMATION_TIME = 1000;
 
 var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
@@ -731,53 +730,6 @@ var LayoutManager = GObject.registerClass({
         this.emit('startup-complete');
     }
 
-    showKeyboard() {
-        this.keyboardBox.show();
-        this.keyboardBox.ease({
-            translation_y: -this.keyboardBox.height,
-            opacity: 255,
-            duration: KEYBOARD_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            onComplete: () => {
-                this._showKeyboardComplete();
-            },
-        });
-        this.emit('keyboard-visible-changed', true);
-    }
-
-    _showKeyboardComplete() {
-        // Poke Chrome to update the input shape; it doesn't notice
-        // anchor point changes
-        this._updateRegions();
-
-        this._keyboardHeightNotifyId = this.keyboardBox.connect('notify::height', () => {
-            this.keyboardBox.translation_y = -this.keyboardBox.height;
-        });
-    }
-
-    hideKeyboard(immediate) {
-        if (this._keyboardHeightNotifyId) {
-            this.keyboardBox.disconnect(this._keyboardHeightNotifyId);
-            this._keyboardHeightNotifyId = 0;
-        }
-        this.keyboardBox.ease({
-            translation_y: 0,
-            opacity: 0,
-            duration: immediate ? 0 : KEYBOARD_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_IN_QUAD,
-            onComplete: () => {
-                this._hideKeyboardComplete();
-            },
-        });
-
-        this.emit('keyboard-visible-changed', false);
-    }
-
-    _hideKeyboardComplete() {
-        this.keyboardBox.hide();
-        this._updateRegions();
-    }
-
     // setDummyCursorGeometry:
     //
     // The cursor dummy is a standard widget commonly used for popup